home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / m68k / fbug68k.arc / MAIN.C < prev    next >
C/C++ Source or Header  |  1989-08-17  |  2KB  |  68 lines

  1. #include"userdef.h"
  2.  
  3. /* ************************************************************** */
  4. /*
  5. This is the main routine. The warm restart will come here. 
  6. The routine consists of an infinite loop, exited by a go, go direct
  7. or trace command.
  8. A prompt is printed, a new command line is obtained. The start of the
  9. command line is checked to see if it matches with a known command. If
  10. so then the program branches to the new command. If the command is
  11. unknown then an error message is printed.  
  12. */
  13. /* ************************************************************** */
  14.  
  15. mainloop()
  16. {
  17. register int i,j;    /* loop counters */
  18. extern char argv[];    /* the command line */
  19. extern char lastcmd[];    /* the last command line */
  20. extern int argc;    /* number of arguments on the command line */
  21. extern int lastargc;    /* number of arguments on the last command line */
  22. extern struct table_element f[];    /* table of commands */
  23.  
  24.     while (TRUE)
  25.     {
  26.         print(PROMPT);
  27.         argc = getline(argv);
  28.         if (argc == 0) 
  29.         {
  30.             if((lastcmd[0]=='t' || lastcmd[0]=='T') &&
  31.                     (lastcmd[1]=='r' || lastcmd[1]=='R'))
  32.             {
  33.             /* ********************************************    */
  34.             /* reset to the last command line if it was tr    */
  35.                 argv[0]='t';
  36.                 argv[1]='r';
  37.                 argv[2]=ENDSTR;
  38.                 argc=1;
  39.             /* ********************************************    */
  40.             }
  41.         }
  42.         if (argc != 0) 
  43.         {
  44.             /* **************************************** */
  45.             /* set up the last command line            */
  46.             for(i=0;(argv[i]!=ENDSTR && i<=MAXLINE);i++)
  47.                 lastcmd[i]=argv[i];
  48.             /* **************************************** */
  49.             for (i=0;f[i].nptr != LASTCMD;i++)
  50.             {
  51.                 for(j=0;f[i].nptr[j] != ENDCMD && argv[j] == f[i].nptr[j];j++)
  52.                     ;
  53.                 if (f[i].nptr[j] == ENDCMD && whitesp(argv[j]))
  54.                     break;
  55.             }
  56.             if (f[i].nptr != LASTCMD)
  57.                 f[i].fptr(argc,argv);
  58.             else
  59.                 print(ERR07);
  60.         }    
  61.         else
  62.             print("\n");
  63.     }
  64.  
  65. /* *************************************************************** */
  66.  
  67.